package com.api.service.v1;

import com.admin.entity.Station;
import com.admin.entity.SystemApk;
import com.admin.entity.Terminal;
import com.admin.mapper.StationMapper;
import com.admin.mapper.SystemApkMapper;
import com.admin.mapper.TerminalMapper;
import com.admin.service.IStationService;
import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SystemApkApiService {


    @Autowired
    private  TerminalApiService terminalApiService;

    @Autowired
    private SystemApkMapper systemApkMapper;

    /**
     * 获取当前APK的版本
     * @param mac
     * @return
     */
    public SystemApk getCurrentVersion(String mac) {
        Station station =  terminalApiService.findStationByMac(mac);
        if (station==null)
        {
            return null;
        }

        Integer  systemAPkID =  station.getStationSystemUpdate();
        if (systemAPkID==null)
        {
            return null;
        }
        SystemApk  systemApk = systemApkMapper.selectById(systemAPkID);
        return systemApk;
    }
}
